#include "light_post.h"
#include "model/lighting.h"

LightPost::LightPost(const Cube& cube,const ObjectModelPtr& model,Light* light)
	: SceneObject(cube,model){
	_light = light;
	if(!_light){
		RGBAColor color(0.8f, 0.6f, 0.0f, 1.0f);
		Point position = cube.center()+Point(0,0,cube.height()/2);
		RGBAColor ambient(0.8f, 0.6f, 0.0f, 1.0f);

		_light = Lighting::instance().createLight(position,color,ambient,0.0f,0.0f,0.005f);
	}
}

LightPost::~LightPost(){
	Lighting::instance().removeLight(_light);
}

void LightPost::state(bool state){
	if(state)
		_light->enable();
	else
		_light->disable();
}

